Originally Posted by
noobiept
I still don't get it, because the || is been evaluated first. Doesn't having higher precedence means that it is evaluated first? This way the && isn't even considered.
First the double || and && are for use in conditionals, not math. For example:
if ((x > 6) || (y < 7))
If you are doing math you use the single versions not the doubles.
For order or precidence the general rule is:
Deepest brackets first, working out.
Once at top level, left to right.
Try your code again using:
Code:
printf("%d ", ++i | ++j & ++k);
printf("i:%d j:%d k:%d", i, j, k);
If you want the AND to run first put brackets like this:
Code:
printf("%d ", ++i | (++j & ++k));
printf("i:%d j:%d k:%d", i, j, k);
Does that help?